#include <stdio.h>
#include <stdlib.h>

int compare(const void *a,const void *b){
    return (*(int*)a-*(int*)b);
}

int main(){
    int array[]={10,1,242,3,64,432,32,325,6523,6023,812};
    int key=rand();
    int *item;
    item=(int*)bsearch(&key,array,11,sizeof(int),compare);
    if(item!=NULL){
        printf("number = %d\n",*item);
    }else{
        printf("Not exist.\n");
    }
    printf("Original array: ");
    for(int i=0;i<11;i++){
        printf("%d ",array[i]);
    }
    putchar('\n');
    qsort(array,11,sizeof(int),compare);
    printf("Sorted array: ");
    for(int i=0;i<11;i++){
        printf("%d ",array[i]);
    }
    putchar('\n');
    return 0;
}
